﻿// Decompiled with JetBrains decompiler
// Type: YJM_PTO.Form3
// Assembly: YJM_PTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 17EE8669-AD07-48C9-A340-87C7401F98C3
// Assembly location: C:\Users\Administrator\Desktop\bin\YJM_PTO.exe

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace YJM_PTO
{
  public class Form3 : Form
  {
    private IContainer components = (IContainer) null;
    private Label label2;
    private Button bntQryCus;
    private Panel panel1;
    private Panel panel2;
    private Label label1;
    private DataGridView dgvPtOList;
    private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
    private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
    private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
    private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
    private DataGridViewTextBoxColumn Column2;
    private DateTimePicker dateTimePicker2;
    private DateTimePicker dateTimePicker1;
    private Label label3;
    private TextBox txtQryInfo;
    private DataGridViewTextBoxColumn Column1;
    private ComboBox cbbOutType;
    private Label label9;

    public Form3() => this.InitializeComponent();

    private void Form3_Load(object sender, EventArgs e)
    {
      this.dateTimePicker1.Value = DateTime.Now.AddMonths(-1);
      this.LoadFile("", "");
      this.LoadOutType();
    }

    private void bntQryCus_Click(object sender, EventArgs e)
    {
      this.LoadFile(this.cbbOutType.Text.Trim(), this.txtQryInfo.Text.Trim());
    }

    public void LoadOutType()
    {
      this.cbbOutType.ItemHeight = 20;
      this.cbbOutType.DrawMode = DrawMode.OwnerDrawVariable;
      Cursor.Current = Cursors.WaitCursor;
      string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "OutModel" + "\\WareHouseOutType.txt";
      if (!File.Exists(path))
        return;
      StreamReader streamReader = new StreamReader((Stream) File.Open(path, FileMode.Open), Encoding.GetEncoding("GB2312"));
      ArrayList arrayList = new ArrayList();
      this.cbbOutType.Items.Clear();
      string str = streamReader.ReadToEnd().Replace("\r\n", "\n");
      streamReader.Close();
      streamReader.Dispose();
      string[] strArray = str.Split('\n');
      string[] items = new string[strArray.Length];
      for (int index = 0; index < strArray.Length; ++index)
        items[index] = strArray[index].Split(':')[0];
      this.cbbOutType.Items.AddRange((object[]) items);
      this.cbbOutType.Items.Insert(0, (object) "");
      this.cbbOutType.SelectedIndex = 0;
      Cursor.Current = Cursors.Default;
    }

    private void cbbOutType_DrawItem(object sender, DrawItemEventArgs e)
    {
      if (e.Index < 0)
        return;
      e.DrawBackground();
      e.DrawFocusRectangle();
      Graphics graphics = e.Graphics;
      string s = this.cbbOutType.Items[e.Index].ToString();
      Font font = e.Font;
      SolidBrush solidBrush = new SolidBrush(e.ForeColor);
      Rectangle bounds = e.Bounds;
      double x = (double) bounds.X;
      bounds = e.Bounds;
      double y = (double) (bounds.Y + 3);
      graphics.DrawString(s, font, (Brush) solidBrush, (float) x, (float) y);
    }

    public void LoadFile(string cbbOutType, string qryinfo)
    {
      string[] array = ((IEnumerable<string>) Directory.GetDirectories(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "ProdToOut")).Select(f => new
      {
        f = f,
        fi = new FileInfo(f)
      }).Where(_param1 => _param1.fi.CreationTime > this.dateTimePicker1.Value && _param1.fi.CreationTime < this.dateTimePicker2.Value && _param1.fi.Name.Contains(cbbOutType) && _param1.fi.Name.Contains(qryinfo)).OrderByDescending(_param1 => _param1.fi.CreationTime).Select(_param1 => _param1.fi.FullName).ToArray<string>();
      this.dgvPtOList.Rows.Clear();
      foreach (string path in array)
      {
        string[] source1 = path.Split('\\');
        string[] source2 = source1[((IEnumerable<string>) source1).Count<string>() - 1].Split('_');
        string s = source2[((IEnumerable<string>) source2).Count<string>() - 1];
        string str1 = source2[0];
        string[] files = Directory.GetFiles(path);
        string str2 = "";
        string str3 = "";
        if (((IEnumerable<string>) files).Count<string>() > 0)
        {
          string fileName = Path.GetFileName(files[0]);
          if (fileName.Contains("出库_"))
            str3 = fileName;
          else
            str2 = fileName;
        }
        if (((IEnumerable<string>) files).Count<string>() > 1)
        {
          string fileName = Path.GetFileName(files[1]);
          if (fileName.Contains("出库_"))
            str3 = fileName;
          else
            str2 = fileName;
        }
        int count = this.dgvPtOList.Rows.Count;
        this.dgvPtOList.Rows.Insert(count, new DataGridViewRow());
        this.dgvPtOList.Rows[count].Cells[0].Value = (object) (count + 1);
        this.dgvPtOList.Rows[count].Cells[1].Value = (object) DateTime.ParseExact(s, "yyMMddHHmmss", (IFormatProvider) CultureInfo.CurrentCulture);
        this.dgvPtOList.Rows[count].Cells[2].Value = (object) str2;
        this.dgvPtOList.Rows[count].Cells[3].Value = (object) str3;
        this.dgvPtOList.Rows[count].Cells[4].Value = (object) path;
        this.dgvPtOList.Rows[count].Cells[5].Value = (object) str1;
      }
    }

    private void dgvPtOList_DoubleClick(object sender, EventArgs e)
    {
      if (this.dgvPtOList.SelectedRows.Count <= 0)
        return;
      Process.Start("explorer.exe", Path.GetDirectoryName(this.dgvPtOList.SelectedRows[0].Cells[4].Value.ToString() + "\\"));
    }

    protected override void Dispose(bool disposing)
    {
      if (disposing && this.components != null)
        this.components.Dispose();
      base.Dispose(disposing);
    }

    private void InitializeComponent()
    {
      this.label2 = new Label();
      this.bntQryCus = new Button();
      this.panel1 = new Panel();
      this.label3 = new Label();
      this.txtQryInfo = new TextBox();
      this.dateTimePicker2 = new DateTimePicker();
      this.dateTimePicker1 = new DateTimePicker();
      this.label1 = new Label();
      this.panel2 = new Panel();
      this.dgvPtOList = new DataGridView();
      this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
      this.dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
      this.dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
      this.dataGridViewTextBoxColumn4 = new DataGridViewTextBoxColumn();
      this.Column2 = new DataGridViewTextBoxColumn();
      this.Column1 = new DataGridViewTextBoxColumn();
      this.cbbOutType = new ComboBox();
      this.label9 = new Label();
      this.panel1.SuspendLayout();
      this.panel2.SuspendLayout();
      ((ISupportInitialize) this.dgvPtOList).BeginInit();
      this.SuspendLayout();
      this.label2.AutoSize = true;
      this.label2.Location = new Point(19, 24);
      this.label2.Name = "label2";
      this.label2.Size = new Size(52, 15);
      this.label2.TabIndex = 13;
      this.label2.Text = "时间：";
      this.bntQryCus.Location = new Point(1149, 28);
      this.bntQryCus.Name = "bntQryCus";
      this.bntQryCus.Size = new Size(75, 29);
      this.bntQryCus.TabIndex = 15;
      this.bntQryCus.Text = "查询";
      this.bntQryCus.UseVisualStyleBackColor = true;
      this.bntQryCus.Click += new EventHandler(this.bntQryCus_Click);
      this.panel1.Controls.Add((Control) this.cbbOutType);
      this.panel1.Controls.Add((Control) this.label9);
      this.panel1.Controls.Add((Control) this.label3);
      this.panel1.Controls.Add((Control) this.txtQryInfo);
      this.panel1.Controls.Add((Control) this.dateTimePicker2);
      this.panel1.Controls.Add((Control) this.dateTimePicker1);
      this.panel1.Controls.Add((Control) this.label1);
      this.panel1.Controls.Add((Control) this.bntQryCus);
      this.panel1.Controls.Add((Control) this.label2);
      this.panel1.Dock = DockStyle.Top;
      this.panel1.Location = new Point(0, 0);
      this.panel1.Name = "panel1";
      this.panel1.Size = new Size(1280, 101);
      this.panel1.TabIndex = 18;
      this.label3.AutoSize = true;
      this.label3.Location = new Point(810, 27);
      this.label3.Name = "label3";
      this.label3.Size = new Size(67, 15);
      this.label3.TabIndex = 27;
      this.label3.Text = "文件名：";
      this.txtQryInfo.Location = new Point(883, 22);
      this.txtQryInfo.Name = "txtQryInfo";
      this.txtQryInfo.Size = new Size(238, 25);
      this.txtQryInfo.TabIndex = 28;
      this.dateTimePicker2.CustomFormat = "yyyy-MM-dd HH:mm:ss";
      this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
      this.dateTimePicker2.Location = new Point(321, 22);
      this.dateTimePicker2.Name = "dateTimePicker2";
      this.dateTimePicker2.Size = new Size(201, 25);
      this.dateTimePicker2.TabIndex = 26;
      this.dateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm:ss";
      this.dateTimePicker1.Format = DateTimePickerFormat.Custom;
      this.dateTimePicker1.Location = new Point(64, 20);
      this.dateTimePicker1.Name = "dateTimePicker1";
      this.dateTimePicker1.Size = new Size(204, 25);
      this.dateTimePicker1.TabIndex = 25;
      this.label1.AutoSize = true;
      this.label1.Location = new Point(285, 25);
      this.label1.Name = "label1";
      this.label1.Size = new Size(22, 15);
      this.label1.TabIndex = 16;
      this.label1.Text = "至";
      this.panel2.Controls.Add((Control) this.dgvPtOList);
      this.panel2.Dock = DockStyle.Fill;
      this.panel2.Location = new Point(0, 101);
      this.panel2.Name = "panel2";
      this.panel2.Size = new Size(1280, 646);
      this.panel2.TabIndex = 19;
      this.dgvPtOList.AllowUserToAddRows = false;
      this.dgvPtOList.AllowUserToDeleteRows = false;
      this.dgvPtOList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
      this.dgvPtOList.BackgroundColor = Color.Honeydew;
      this.dgvPtOList.BorderStyle = BorderStyle.None;
      this.dgvPtOList.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
      this.dgvPtOList.Columns.AddRange((DataGridViewColumn) this.dataGridViewTextBoxColumn1, (DataGridViewColumn) this.dataGridViewTextBoxColumn2, (DataGridViewColumn) this.dataGridViewTextBoxColumn3, (DataGridViewColumn) this.dataGridViewTextBoxColumn4, (DataGridViewColumn) this.Column2, (DataGridViewColumn) this.Column1);
      this.dgvPtOList.Dock = DockStyle.Fill;
      this.dgvPtOList.GridColor = Color.Honeydew;
      this.dgvPtOList.Location = new Point(0, 0);
      this.dgvPtOList.Margin = new Padding(4);
      this.dgvPtOList.MultiSelect = false;
      this.dgvPtOList.Name = "dgvPtOList";
      this.dgvPtOList.ReadOnly = true;
      this.dgvPtOList.RowTemplate.Height = 23;
      this.dgvPtOList.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
      this.dgvPtOList.Size = new Size(1280, 646);
      this.dgvPtOList.TabIndex = 24;
      this.dgvPtOList.Tag = (object) "dgvStopDevList";
      this.dgvPtOList.DoubleClick += new EventHandler(this.dgvPtOList_DoubleClick);
      this.dataGridViewTextBoxColumn1.FillWeight = 30.79317f;
      this.dataGridViewTextBoxColumn1.HeaderText = "序号";
      this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
      this.dataGridViewTextBoxColumn1.ReadOnly = true;
      this.dataGridViewTextBoxColumn2.FillWeight = 73.92893f;
      this.dataGridViewTextBoxColumn2.HeaderText = "时间";
      this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
      this.dataGridViewTextBoxColumn2.ReadOnly = true;
      this.dataGridViewTextBoxColumn3.FillWeight = 162.4366f;
      this.dataGridViewTextBoxColumn3.HeaderText = "生产文件";
      this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
      this.dataGridViewTextBoxColumn3.ReadOnly = true;
      this.dataGridViewTextBoxColumn4.FillWeight = 132.8413f;
      this.dataGridViewTextBoxColumn4.HeaderText = "出库文件";
      this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
      this.dataGridViewTextBoxColumn4.ReadOnly = true;
      this.Column2.HeaderText = "路径";
      this.Column2.Name = "Column2";
      this.Column2.ReadOnly = true;
      this.Column2.Visible = false;
      this.Column1.HeaderText = "出库类型";
      this.Column1.Name = "Column1";
      this.Column1.ReadOnly = true;
      this.cbbOutType.DrawMode = DrawMode.OwnerDrawVariable;
      this.cbbOutType.DropDownStyle = ComboBoxStyle.DropDownList;
      this.cbbOutType.FormattingEnabled = true;
      this.cbbOutType.ItemHeight = 20;
      this.cbbOutType.Location = new Point(592, 20);
      this.cbbOutType.Name = "cbbOutType";
      this.cbbOutType.Size = new Size(204, 26);
      this.cbbOutType.TabIndex = 30;
      this.cbbOutType.DrawItem += new DrawItemEventHandler(this.cbbOutType_DrawItem);
      this.label9.AutoSize = true;
      this.label9.Location = new Point(547, 27);
      this.label9.Name = "label9";
      this.label9.Size = new Size(52, 15);
      this.label9.TabIndex = 29;
      this.label9.Text = "类型：";
      this.AutoScaleDimensions = new SizeF(8f, 15f);
      this.AutoScaleMode = AutoScaleMode.Font;
      this.ClientSize = new Size(1280, 747);
      this.Controls.Add((Control) this.panel2);
      this.Controls.Add((Control) this.panel1);
      this.MaximizeBox = false;
      this.MinimizeBox = false;
      this.Name = "Form3";
      this.StartPosition = FormStartPosition.CenterParent;
      this.Text = "历史记录";
      this.Load += new EventHandler(this.Form3_Load);
      this.panel1.ResumeLayout(false);
      this.panel1.PerformLayout();
      this.panel2.ResumeLayout(false);
      ((ISupportInitialize) this.dgvPtOList).EndInit();
      this.ResumeLayout(false);
    }
  }
}
